package com.example.com.skills_utf8;

import android.app.ActionBar;
import android.app.Activity;
import android.app.Dialog;
import android.app.DownloadManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ScrollView;

import com.app.util.Utils;
import com.cosplay.pulltorefresh.level._46Activity;
import com.example.zbar2.CaptureActivity;
import com.pic.PicControlActivity;
import com.utils.TIME;
import com.utils.Toolkit;
import com.utils.Utils1;
import com.video.VideoActivity;

import pullscrollview.ui._39MainActivity;
import service.MyRemoteService;
import use_google.useGoogle29;
import use_ndk._37ShakeActivity;
import use_tooljar.USETOOLJAR;

public class MainActivity extends Activity implements OnClickListener {

	MainActivity activity =this;
	
	ActionBar mActionBar ;

	Handler handler = new Handler();
	private ScrollView scrollview;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		 
		Button btn1 = (Button)findViewById(R.id.btn1);
		Button btn2 = (Button)findViewById(R.id.btn2);
		Button btn3 = (Button)findViewById(R.id.btn3);
		Button btn4 = (Button)findViewById(R.id.btn4);
		Button btn5 = (Button)findViewById(R.id.btn5);
		Button btn6 = (Button)findViewById(R.id.btn6);
		Button btn7 = (Button)findViewById(R.id.btn7);
		Button btn8 = (Button)findViewById(R.id.btn8);
		Button btn9 = (Button)findViewById(R.id.btn9);
		Button btn10 = (Button)findViewById(R.id.btn10);
		Button btn11 = (Button)findViewById(R.id.btn11);
		Button btn12 = (Button)findViewById(R.id.btn12);
		Button btn13 = (Button)findViewById(R.id.btn13);
		Button btn14 = (Button)findViewById(R.id.btn14);
		Button btn15 = (Button)findViewById(R.id.btn15);
		Button btn16 = (Button)findViewById(R.id.btn16);
		Button btn17 = (Button)findViewById(R.id.btn17);
		Button btn18 = (Button)findViewById(R.id.btn18);
		Button btn19 = (Button)findViewById(R.id.btn19);
		Button btn20 = (Button)findViewById(R.id.btn20);
		Button btn21 = (Button)findViewById(R.id.btn21);
		Button btn22 = (Button)findViewById(R.id.btn22);
		Button btn23 = (Button)findViewById(R.id.btn23);
		Button btn24 = (Button)findViewById(R.id.btn24);
		Button btn25 = (Button)findViewById(R.id.btn25);
		Button btn26 = (Button)findViewById(R.id.btn26);
		Button btn27 = (Button)findViewById(R.id.btn27);
		Button btn28 = (Button)findViewById(R.id.btn28);
		Button btn29 = (Button)findViewById(R.id.btn29);
		Button btn30 = (Button)findViewById(R.id.btn30);
		Button btn31 = (Button)findViewById(R.id.btn31);
		Button btn32 = (Button)findViewById(R.id.btn32);
		Button btn33 = (Button)findViewById(R.id.btn33);
		Button btn34 = (Button)findViewById(R.id.btn34);
		Button btn35 = (Button)findViewById(R.id.btn35);
		Button btn36 = (Button)findViewById(R.id.btn36);
		Button btn37 = (Button)findViewById(R.id.btn37);
		Button btn38 = (Button)findViewById(R.id.btn38);
		Button btn39 = (Button)findViewById(R.id.btn39);
		Button btn40 = (Button)findViewById(R.id.btn40);
		Button btn41 = (Button)findViewById(R.id.btn41);
		Button btn42 = (Button)findViewById(R.id.btn42);
		Button btn43 = (Button)findViewById(R.id.btn43);
		Button btn44 = (Button)findViewById(R.id.btn44);
		Button btn45 = (Button)findViewById(R.id.btn45);
		Button btn46 = (Button)findViewById(R.id.btn46);
		Button btn47 = (Button)findViewById(R.id.btn47);
		Button btn48 = (Button)findViewById(R.id.btn48);
		Button btn49 = (Button)findViewById(R.id.btn49);
		Button btn50 = (Button)findViewById(R.id.btn50);
		Button btn51 = (Button)findViewById(R.id.btn51);
		Button btn52 = (Button)findViewById(R.id.btn52);
		Button btn53 = (Button)findViewById(R.id.btn53);
		Button btn54 = (Button)findViewById(R.id.btn54);
		Button btn55 = (Button)findViewById(R.id.btn55);
		Button btn56 = (Button)findViewById(R.id.btn56);
		Button btn57 = (Button)findViewById(R.id.btn57);
		Button btn58 = (Button)findViewById(R.id.btn58);
		Button btn59 = (Button)findViewById(R.id.btn59);
		Button btn60 = (Button)findViewById(R.id.btn60);
		Button btn61 = (Button)findViewById(R.id.btn61);
		Button btn62 = (Button)findViewById(R.id.btn62);
		Button btn63 = (Button)findViewById(R.id.btn63);
		Button btn64 = (Button)findViewById(R.id.btn64);
		Button btn65 = (Button)findViewById(R.id.btn65);
		Button btn66 = (Button)findViewById(R.id.btn66);
		Button btn67 = (Button)findViewById(R.id.btn67);
		Button btn68 = (Button)findViewById(R.id.btn68);
		Button btn69 = (Button)findViewById(R.id.btn69);
		Button btn70 = (Button)findViewById(R.id.btn70);
		Button btn71 = (Button)findViewById(R.id.btn71);
		Button btn72 = (Button)findViewById(R.id.btn72);
		Button btn73 = (Button)findViewById(R.id.btn73);
		Button btn74 = (Button)findViewById(R.id.btn74);

		
		btn1.setOnClickListener(this);
		btn2.setOnClickListener(this);
		btn3.setOnClickListener(this);
		btn4.setOnClickListener(this);
		btn5.setOnClickListener(this);
		btn6.setOnClickListener(this);
		btn7.setOnClickListener(this);
		btn8.setOnClickListener(this);
		btn9.setOnClickListener(this);
		btn10.setOnClickListener(this);
		btn11.setOnClickListener(this);
		btn12.setOnClickListener(this);
		btn13.setOnClickListener(this);
		btn14.setOnClickListener(this);
		btn15.setOnClickListener(this);
		btn16.setOnClickListener(this);
		btn17.setOnClickListener(this);
		btn18.setOnClickListener(this);
		btn19.setOnClickListener(this);
		btn20.setOnClickListener(this);
		btn21.setOnClickListener(this);
		btn22.setOnClickListener(this);
		btn23.setOnClickListener(this);
		btn24.setOnClickListener(this);
		btn25.setOnClickListener(this);
		btn26.setOnClickListener(this);
		btn27.setOnClickListener(this);
		btn28.setOnClickListener(this);
		btn29.setOnClickListener(this);
		btn30.setOnClickListener(this);
		btn31.setOnClickListener(this);
		btn32.setOnClickListener(this);
		btn33.setOnClickListener(this);
		btn34.setOnClickListener(this);
		btn35.setOnClickListener(this);
		btn36.setOnClickListener(this);
		btn37.setOnClickListener(this);
		btn38.setOnClickListener(this);
		btn39.setOnClickListener(this);
		btn40.setOnClickListener(this);
		btn41.setOnClickListener(this);
		btn42.setOnClickListener(this);
		btn43.setOnClickListener(this);
		btn44.setOnClickListener(this);
		btn45.setOnClickListener(this);
		btn46.setOnClickListener(this);
		btn47.setOnClickListener(this);
		btn48.setOnClickListener(this);
		btn49.setOnClickListener(this);
		btn50.setOnClickListener(this);
		btn51.setOnClickListener(this);
		btn52.setOnClickListener(this);
		btn53.setOnClickListener(this);
		btn54.setOnClickListener(this);
		btn55.setOnClickListener(this);
		btn56.setOnClickListener(this);
		btn57.setOnClickListener(this);
		btn58.setOnClickListener(this);
		btn59.setOnClickListener(this);
		btn60.setOnClickListener(this);
		btn61.setOnClickListener(this);
		btn62.setOnClickListener(this);
		btn63.setOnClickListener(this);
		btn64.setOnClickListener(this);
		btn65.setOnClickListener(this);
		btn66.setOnClickListener(this);
		btn67.setOnClickListener(this);
		btn68.setOnClickListener(this);
		btn69.setOnClickListener(this);
		btn70.setOnClickListener(this);
		btn71.setOnClickListener(this);
		btn72.setOnClickListener(this);
		btn73.setOnClickListener(this);
		btn74.setOnClickListener(this);


	//	int i =1/0;

		
		Utils.ShowToastCustom(activity, "将自动滚动到底部~");
		scrollview = (ScrollView)findViewById(R.id.scrollview);
		handler.postDelayed(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				scrollview.fullScroll(View.FOCUS_DOWN);
				
			}
		}, 1000);
		
	////////////////////////////////////////////////////
		
		//test();
	//	test1();

		// 开启远程服务，
		activity.startService(new Intent(activity, MyRemoteService.class));

		/*
		//
		// 初始化友盟
		UmengUpdateAgent.setUpdateCheckConfig(true);
		UmengUpdateAgent.setAppkey("5511252cfd98c54de5000996");
		Umeng.OnCreate_update_init(this);

		UmengUpdateAgent.setUpdateAutoPopup(false);
		UmengUpdateAgent.setUpdateListener(new UmengUpdateListener() {
			@Override
			public void onUpdateReturned(int updateStatus,UpdateResponse updateInfo) {
				switch (updateStatus) {
					case UpdateStatus.Yes: // has update
						UmengUpdateAgent.showUpdateDialog(activity, updateInfo);
						break;
					case UpdateStatus.No: // has no update
						Toast.makeText(activity, "当前为最新版本", Toast.LENGTH_SHORT).show();
						break;
					case UpdateStatus.NoneWifi: // none wifi
						Toast.makeText(activity, "没有wifi连接， 只在wifi下更新", Toast.LENGTH_SHORT).show();
						break;
					case UpdateStatus.Timeout: // time out
						Toast.makeText(activity, "超时", Toast.LENGTH_SHORT).show();
						break;
				}
			}
		});
		UmengUpdateAgent.forceUpdate(getApplicationContext());
		*/

	}


	void test(){

		final Dialog dialog = new Dialog(activity);
		dialog.setContentView(R.layout.activity_main);
		Handler handler = new Handler(){
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);

				dialog.show();
			}
		};
		/*
		handler.postDelayed(new Runnable() {
			@Override
			public void run() {
				dialog.show();
			}
		}, 1000);
		*/
		final Message msg_show = handler.obtainMessage(1);

		new Thread(){
			@Override
			public void run() {
				super.run();
				dialog.setOnShowListener(new DialogInterface.OnShowListener() {
					@Override
					public void onShow(DialogInterface dialog) {
						Utils.showToastShort(activity, "hi");

					}
				});


				Message.obtain(msg_show).sendToTarget();


			}
		}.start();
	}



	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
		switch(v.getId())
		{
			case R.id.btn1:{
			
				Intent intent = new Intent( activity, ShopsCommentActivity.class);
				startActivity(intent);
				
				
				break;
			}
				
			case R.id.btn2:{
				
				break;
			}
			
			case R.id.btn3:{
				Intent intent = new Intent( activity, EmptyListViewActivity.class);
				startActivity(intent);
				
				break;
			}
			case R.id.btn4:{
				Intent intent = new Intent( activity, LoadMoreListViewActivity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn5:{
				Intent intent = new Intent( activity, ActionBarTabs.class);
				startActivity(intent);
				
						
				break;
			}
			
			case R.id.btn6:{
				
				Intent intent = new Intent( activity, OpenglActivity.class);
				startActivity(intent);
			
		//		Intent intent = new Intent( activity, TranslucentGLSurfaceViewActivity.class);
		//		startActivity(intent);
				
				
						
				break;
			}
			
			case R.id.btn7:{
				
				Intent intent = new Intent( activity, FragmentStack.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn8:{
				
				Intent intent = new Intent( activity, SupportFragmentStack.class);
				startActivity(intent);
				
				break;
			}

			case R.id.btn9:{
				
				Intent intent = new Intent( activity, FragmentTabs.class);
				startActivity(intent);
				
				break;
			}
	
			case R.id.btn10:{
				
				Intent intent = new Intent( activity, IsRunningActivity.class);
				startActivity(intent);
				
				break;
			}
			case R.id.btn11:{
				
				Intent intent = new Intent( activity, BluetoothServerActivity.class);
				startActivity(intent);
				
				break;
			}
	
			case R.id.btn12:{
				
				Intent intent = new Intent( activity, AnimationActivity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn13:{
				
				Intent intent = new Intent( activity, ProgressBarActivity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn14:{
				
				Intent intent = new Intent( activity, ProgressBar1Activity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn15:{
				
				Intent intent = new Intent( activity, MyTabActivity.class);
				startActivity(intent);
				
				break;
			}
			case R.id.btn16:{
				
				Intent intent = new Intent( activity, MyFragmentTabActivity.class);
				startActivity(intent);
				
				break;
			}

			case R.id.btn17:{
				
				Intent intent = new Intent( activity, ImageTextViewActivity.class);
				startActivity(intent);
				
				break;
			}
			
			case R.id.btn18:{
				
				Intent intent = new Intent( activity, UseScrollLayoutActivity.class);
				startActivity(intent);
				
				break;
			}
			
			
			case R.id.btn19:{
				

						new Thread(){
							public void run() {
								
								
								// DownloadManager http://www.cnblogs.com/abob/archive/2009/07/09/1520021.html
								
								
								
								DownloadManager.Request  download = new DownloadManager.Request(
										Uri.parse( "http://img.meilishuo.net/css/images/AndroidShare/Meilishuo_3.6.1_10006.apk" )
										//Uri.parse("http://192.168.0.137/Shenlou_DEMO.exe") 
										);
								
								
								
								/*
								String url ="";
								String title ="";
							      ContentValues values = new ContentValues();
						         values.put(android.provider.D.URI, url);//指定下载地址
						         values.put(Downloads.TITLE,title);//设置下载任务的名称
						         activity.getContentResolver().insert(Downloads.CONTENT_URI, values);//将其插入到DownloadManager的数据库中，数据库会触发修改事件，启动下载任务
						         */
								
								DownloadManager dm = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
								long download_id =dm.enqueue(download);
							
								
								
								final long last_recive = Toolkit.getNetworkSpeed();
							//	for(;;)
								{
									
									new TIME(){

										@Override
										public void fuc() {
											// TODO Auto-generated method stub
											
											// 运行一次 
											long recive =Toolkit.getNetworkSpeed();
											System.out.println(recive-last_recive);
											System.out.println(Utils1.byte2KB(recive-last_recive));
											System.out.println(Utils1.byte2MB(recive-last_recive));
										}
										
									}.time_to_go(10000); //10秒钟的下载量. 得出kb/s.. 300kb/s左右
							
									
									
								
								}
								// 写个自定义的view呢.. 用来不断显示调试信息.
								
							};
							
						}.start();
						
						break;
				}
			
			case R.id.btn20:{
				Intent intent = new Intent(activity, DIYViewActivity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn21:{
				Intent intent = new Intent(activity, NFCActivity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn22:{
				Intent intent = new Intent(activity, TTActivity.class);
				startActivity(intent);
				break;
			}

			case R.id.btn23:{
				Intent intent = new Intent(activity, TT_SimpleActivity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn24:{
				Intent intent = new Intent(activity, ChangeView24.class);
				startActivity(intent);
				break;
			}
			
			
			case R.id.btn25:{
				Intent intent = new Intent(activity, slidingdrawer_25Activity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn26:{
				Intent intent = new Intent(activity, Theme26Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn27:{
				Intent intent = new Intent(activity, ActionBar27Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn28:{
				Intent intent = new Intent(activity, USETOOLJAR.class);
				startActivity(intent);
				break;
			}			
			case R.id.btn29:{
				Intent intent = new Intent(activity, useGoogle29.class);
				startActivity(intent);
				break;
			}	
			case R.id.btn30:{
				Intent intent = new Intent(activity, OnItemClickPlusPos30Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn31:{
				Intent intent = new Intent(activity, Sensor31Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn32:{
				Intent intent = new Intent(activity, ExpandableListView32Activity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn33:{
				
				Intent intent = new Intent(activity, CopyOfExpandableListView33Activity.class);
			//	Intent intent = new Intent(activity, ExpandableListView33Activity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn34:{
				Intent intent = new Intent(activity, _34PostStringActivity.class);
				startActivity(intent);
				break;
			}
			
			case R.id.btn35:{
				_startActivity(_35Activity.class);
				break;
			}
			
			case R.id.btn36:{
				Intent intent = new Intent(activity, _36Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn37:{
				Intent intent = new Intent(activity, _37ShakeActivity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn38:{
				Intent intent = new Intent(activity, _38Activity.class);
				startActivity(intent);
				break;
				
			}
			case R.id.btn39:{
				Intent intent = new Intent(activity, _39MainActivity.class);
				startActivity(intent);
				break;
				
			}
			case R.id.btn40:{
				Intent intent = new Intent(activity, _40MainActivity.class);
				startActivity(intent);
				break;
				
			}
			case R.id.btn41:{
				Intent intent = new Intent(activity, _41MainActivity.class);
				startActivity(intent);
				break;
				
			}
			case R.id.btn42:{
				Intent intent = new Intent(activity, _42MainActivity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn43:
			{
				Intent intent = new Intent(activity, _43Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn44:
			{
				Intent intent = new Intent(activity, _44Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn45:
			{
				Intent intent = new Intent(activity, _45Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn46:
			{
				Intent intent = new Intent(activity, _46Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn47:
			{
				Intent intent = new Intent(activity, _47Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn48:{
				Intent intent = new Intent(activity, _48Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn49:{
				startActivity( new Intent(activity, _49Activity.class) );
				break;
			}
			case R.id.btn50:{
				startActivity( new Intent(activity, _50Activity.class) );
				break;
			}
			case R.id.btn51:{
				Intent intent = new Intent(activity, _51Activity.class);
				startActivity(intent);
				break;
			}
			case R.id.btn52:{
				startActivity( new Intent(activity, _52Activity.class) );
				break;
			}
			case R.id.btn53:{
				startActivity( new Intent(activity, _53Activity.class) );
				break;
				
			}
			case R.id.btn54:{
				startActivity( new Intent(activity, _54Activity.class) );
				break;
			}
			case R.id.btn55:{
				startActivity( new Intent(activity, _55Activity.class));
				break;
			}
			case R.id.btn56:{
				startActivity( new Intent(activity, _56Activity.class));
				break;
			}
			
			case R.id.btn57:{
				startActivity(new Intent(activity, _57Activity.class));
				break;
			}
			case R.id.btn58:{
				startActivity(new Intent(activity, _58Activity.class));
				break;
			}
			case R.id.btn59:{
				startActivity(new Intent(activity, VideoActivity.class));
				break;
			}
			case R.id.btn60:{
				startActivity(new Intent(activity, PicControlActivity.class));
				break;

			}
			case R.id.btn61:{
				startActivity(new Intent(activity, _61Activity.class));
				break;

			}
			case R.id.btn62:{
				startActivity(new Intent(activity,_62LoginActivity.class));
				break;

			}
			case R.id.btn63:{
				startActivity(new Intent(activity, _63Activity.class));
				break;
			}
			case R.id.btn64:{
				startActivity(new Intent(activity, _64Activity.class));
				break;
			}
			case R.id.btn65:{
				startActivity(new Intent(activity, _65Activity.class));
				break;
			}

			case R.id.btn66:{
				startActivity(new Intent(activity, CaptureActivity.class));
				break;

			}

			case R.id.btn67:{
				startActivity(new Intent(activity, _67Activity.class));
				break;
			}

			case R.id.btn68:{
				startActivity(new Intent(activity, _68Activity.class));
				break;

			}
			case R.id.btn69:{
				startActivity(new Intent(activity, _69Activity.class));
				break;
			}
			case R.id.btn70:{
				startActivity(new Intent(activity, _70Activity.class));
				break;
			}
			case R.id.btn71:{
				startActivity(new Intent(activity, _71Activity.class));
				break;
			}
			case R.id.btn72:{
				startActivity(new Intent(activity, _72Activity.class));
				break;
			}
			case R.id.btn73:{
				startActivity(new Intent(activity, _73Activity.class));
				break;
			}
			case R.id.btn74:{
				startActivity(new Intent(activity, _74Activity.class));
				break;
			}



		}
		
		
	}

	
	// 
	void _startActivity(Class<?> cls){
		
		Intent intent = new Intent(activity, cls);
		startActivity(intent);
	}
	
	


}
